package com.es.listener;

import com.es.event.PhoneEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * 相当于订阅者
 */
@Component
@Slf4j
public class PhoneEventListener {

    /**
     * 监听手机到货的事件
     *
     * @param event
     */
    @EventListener
    public void listener(PhoneEvent event) {
        log.info("[info信息]收到商店的邮件：{}",event.getArrivalNotice());
        log.error("[error信息]收到商店的邮件：{}",event.getArrivalNotice());
        System.out.println("[控制台信息]收到商店的邮件：" + event.getArrivalNotice());
    }
}
